Skip to content

Conversation

AnatoliB
Copy link
Contributor

@AnatoliB AnatoliB commented Jun 13, 2025

Add 'version' property to the context object passed to orchestrator functions.

As a result, Python Functions users will be able to specify a version in host.json:

{
  "extensions": {
    "durableTask": {
      "defaultVersion": "2.0"
    }
  }
}

and check the orchestration version in their orchestrator functions in order to keep them backward compatible, for example:

if (context.version == "1.0"):
    # Legacy code path
    activity_result = yield context.call_activity("A")
else:
    # New code path
    activity_result = yield context.call_activity("B")

Note: Microsoft.Azure.WebJobs.Extensions.DurableTask 3.1.0+ is required for this to work properly.

@AnatoliB AnatoliB force-pushed the anatolib/context-version branch from 849dbe7 to 86326ea Compare June 13, 2025 02:12
@AnatoliB AnatoliB requested a review from Copilot June 13, 2025 02:12
@AnatoliB AnatoliB marked this pull request as ready for review June 13, 2025 02:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a version property on the DurableOrchestrationContext so orchestrator functions can detect their configured version, updates tests to cover this behavior, and adds a sample app showing how to use it.

  • Extracts the first ExecutionStarted event’s version and exposes it via context.version.
  • Adds unit tests to verify version detection and fallback to None.
  • Provides a sample Function app and configuration demonstrating versioned orchestrations.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/models/test_DurableOrchestrationContext.py Added tests for extracting version from history events.
samples-v2/orchestration_versioning/requirements.txt Added dependencies for the versioning sample.
samples-v2/orchestration_versioning/host.json Configured "defaultVersion" under durableTask.
samples-v2/orchestration_versioning/function_app.py Demonstrated branching logic on context.version.
azure/durable_functions/models/DurableOrchestrationContext.py Implemented _version field, version property, and extraction.
Comments suppressed due to low confidence (1)

samples-v2/orchestration_versioning/function_app.py:5

  • [nitpick] Variable myApp uses camelCase, which deviates from PEP8 snake_case conventions. Consider renaming to my_app or app for consistency.
myApp = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)

@AnatoliB AnatoliB requested a review from cgillum June 18, 2025 22:57
@AnatoliB AnatoliB merged commit 97a0891 into dev Jun 25, 2025
5 checks passed
@AnatoliB AnatoliB deleted the anatolib/context-version branch June 25, 2025 22:53
greenie-msft pushed a commit to greenie-msft/azure-functions-durable-python that referenced this pull request Sep 25, 2025
Add version property to DurableOrchestrationContext class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants